package vn.personal.anhht.bloback12.adapter;

import java.util.List;

import vn.personal.anhht.bloback12.activity.R;
import vn.personal.anhht.bloback12.bean.SMSLogObject;
import vn.personal.anhht.bloback12.util.Constants;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

public class SMSLogAdapter extends ArrayAdapter<SMSLogObject>{
	
	private List<SMSLogObject> items;
	public SMSLogAdapter(Context context, int textViewResourceId,
			List<SMSLogObject> items) {
		super(context, textViewResourceId, items);
		// TODO Auto-generated constructor stub
		this.items = items;
		
	}
	
	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		View v = convertView;
        if (v == null) {
            LayoutInflater vi = (LayoutInflater)getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            v = vi.inflate(R.layout.custom_row_sms_recycle, null);
        }
        final SMSLogObject item = items.get(position);
        if(item != null){
        	
        	/*TextView tvName = (TextView)v.findViewById(R.id.tv_plog_name);
        	if(tvName != null){ 
        		if(item.getName() == null){
        			tvName.setText("No name");
        		}else{
        			tvName.setText(item.getName());
        		}
        	}*/
        	TextView tvPhone = (TextView)v.findViewById(R.id.tv_sms_stuff_phone);
        	if(Constants.CHECK_LOG_ACTIVITY){
        		if(tvPhone != null) tvPhone.setText(item.getName());
        	}else{
        		if(tvPhone != null) tvPhone.setText(item.getPhone());
        	}
        	
        	TextView tvTime = (TextView)v.findViewById(R.id.tv_sms_stuff_time);
        	if(tvTime != null) tvTime.setText(item.getTime());
        	TextView tvContent = (TextView)v.findViewById(R.id.tv_sms_stuff_briefcontent); 	
        	if(tvContent != null){
        		tvContent.setText(item.getMessage());
        	}
        }
		return v;
		
	}
}
